<template>
    <el-container class="content">
        <el-aside width="200px">
            <el-menu :default-active="activeIndex" class="menu" router @open="handleOpen" :default-openeds="defaultOpeneds" unique-opened>
                <el-submenu index="1" title>
                    <template slot="title">
                        <span>会员中心</span>
                    </template>
                    <el-menu-item index="index">欢迎页</el-menu-item>
                    <el-menu-item index="info">个人信息</el-menu-item>
                    <el-menu-item index="security">账户安全</el-menu-item>
                    <el-menu-item index="delivery_address">收货地址</el-menu-item>
                    <el-menu-item index="collection">我的关注</el-menu-item>
                    <el-menu-item index="footprint">我的足迹</el-menu-item>
                </el-submenu>
                <el-submenu index="2" title>
                    <template slot="title">
                        <span>交易中心</span>
                    </template>
                    <el-menu-item index="order_list">我的订单</el-menu-item>
                    <el-menu-item index="activist">退款/售后</el-menu-item>
                    <el-menu-item index="own_pindan">我的拼单</el-menu-item>
                    <template v-if="is_verify == 1">
                        <el-menu-item index="verification">核销台</el-menu-item>
                        <el-menu-item index="verification_list">核销记录</el-menu-item>
                    </template>
                </el-submenu>
                <el-submenu index="3" title>
                    <template slot="title">
                        <span>账户中心</span>
                    </template>
                    <el-menu-item index="account">账户余额</el-menu-item>
                    <el-menu-item index="withdrawal">提现记录</el-menu-item>
                    <el-menu-item index="my_coupon">我的优惠券</el-menu-item>
                    <el-menu-item index="my_point">我的积分</el-menu-item>
					<el-menu-item index="account_list">账户列表</el-menu-item>
                    <!-- <el-menu-item index="level">会员等级</el-menu-item> -->
                </el-submenu>
                <el-submenu index="4" title v-if="memberInfos.member_type == 2">
                    <template slot="title">
                        <span>商会中心</span>
                    </template>
                    <el-menu-item index="zijiguanli">子账号</el-menu-item>
                    <el-menu-item index="subordinate_company">下属企业</el-menu-item>
                </el-submenu>
                <!--到时候有判断是否显示,只有上级代理商才能审核，根据是否是上级代理商，显示与隐藏-->
                 <el-submenu index="5" title v-if="memberInfo.pintuan_trader_level=='district' || memberInfo.pintuan_trader_level=='city'">
                    <template slot="title">
                        <span>代理商</span>
                    </template>
                    <el-menu-item index="check_list">审核</el-menu-item>
                    <el-menu-item index="pingtuanlist">下级团长</el-menu-item> 
                </el-submenu>
                <!-- v-if="memberInfo && memberInfo.pintuan_trader_level!=''" -->
                <el-submenu index="6" title >
                    <template slot="title">
                        <span>团长批发</span>
                    </template>
                    <el-menu-item index="competitive">批发竞标</el-menu-item> 
                    <el-menu-item index="my_particulars">我的竞标</el-menu-item> 
                    <el-menu-item index="pintuanguanli">批发管理</el-menu-item>
                    <el-menu-item index="pintuan_order">团长订单</el-menu-item> 
                </el-submenu>
                <!-- <el-submenu index="7" title v-if="memberInfos && memberInfos.is_pickpoint == 1">
                    <template slot="title">
                        <span>自提点</span>
                    </template>
                    <el-menu-item index="pickup_list">自提点列表</el-menu-item>
                </el-submenu> -->
            </el-menu>
        </el-aside>
        <el-main class="member">
            <transition name="slide"><router-view /></transition>
        </el-main>
    </el-container>
</template>
<script>
    import { checkisverifier } from "@/api/order/verification"
    import { memberDetails } from '@/api/member/index'
    import {  memberDetail } from '@/api/pintuan/pintuan'
import member from '@/store/modules/member'
    export default {
        name: "home",
        components: {},
        data: () => {
            return {
                defaultOpeneds: ["1"],
                activeIndex: "index",
                is_verify: 1,
                memberInfo: '',  //拼团个人详情
                memberInfos: '', //用户个人详情
                pintuantraderDetail: null,//拼团商详情
            }
        },
        created() {
            this.activeIndex = this.$route.meta.parentRouter ||this.$route.path.replace("/member/", "")
            this.checkIsVerifier()
            this.getMemberDeatil()
            this.getMemberDeatils()
        },
        methods: {
            handleOpen(key, keyPath) {
                this.defaultOpeneds = keyPath
            },
            checkIsVerifier() {
                checkisverifier()
                    .then(res => {
                        if (res.data && res.code == 0) {
                            this.is_verify = 1
                        }
                    })
                    .catch(err => {
                        this.is_verify = 0
                    })
            },
            getMemberDeatil() {
                memberDetail()
                    .then(res => {
                        if(res.code ==0 && res.data){
                            this.memberInfo = res.data
                        }
                    })
                    .catch(err => {
                        console.log(err)
                    })
            },
            getMemberDeatils() {
                memberDetails()
                .then(res => {
                        if(res.code ==0 && res.data){
                            this.memberInfos = res.data
                        }
                    })
                    .catch(err => {
                        console.log(err)
                    })
            }
        },
        watch: {
            $route(curr) {
				this.activeIndex = curr.meta.parentRouter||this.$route.path.replace("/member/", "");
                this.getMemberDeatil()
                this.getMemberDeatils()
            }
        }
    }
</script>
<style lang="scss" scoped>
    .menu {
        min-height: 730px;
    }
    .content {
        display: flex !important;
        margin: 20px 0;
    }
    .member {
        margin-left: 15px;
    }
</style>
